home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 6931 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.0 KB

  1. Path: nuscc.nus.sg!chiateck
  2. From: chiateck@iscs.nus.sg (Chia Teck Chin Joseph)
  3. Newsgroups: comp.lang.c++
  4. Subject: Visual C++ and DLL
  5. Date: 16 Feb 1996 06:36:19 GMT
  6. Organization: National University of Singapore
  7. Message-ID: <4g18l3$j55@nuscc.nus.sg>
  8. NNTP-Posting-Host: chiateck@sununx.iscs.nus.sg
  9. X-Newsreader: TIN [version 1.2 PL2]
  10.  
  11. Hi,
  12.     I am having a hard time with the following problem:
  13.  
  14.     I am writing a dll in MSVC++2.1 on NT3.5.
  15.  
  16.     In this dll, i am retrieveing some data from a remote 
  17. computer,storing it in CStringArray.
  18.  
  19.     Subsequently, clients can call functions in this dll to retrieve the 
  20. data.
  21.  
  22.     I found that the following does not return the char* properly.
  23.  
  24. ---------------------------------------------------------------------------
  25.  
  26.    void retrieve(char* s)
  27.    {
  28.      CString temp=happy->GetAt(0);
  29.      strncpy(s,temp,temp.GetLength());
  30.      return;
  31.    };
  32.  
  33.    prior to calling this function, user would need to call another 
  34. function in the dll, as below:
  35.  
  36.     void initialise()
  37.     {
  38.        temp->SetSize(50,10);
  39.        
  40.        //retrieve data from remote site and store in CStringArray
  41.        ...
  42.         
  43.        return;
  44.     };
  45.  
  46.     Note:  happy is a CStringArray* declared as a global variable in the dll.
  47.  
  48.     I am using explicit dynamic loading. But I don't think it matters.
  49.  
  50.     I tried several other ways, like copying the contents from the CString
  51.     bit by bit, but still upon returning, the value doesn't stick to the
  52.     parameter char* s?
  53.  
  54.     I have spent so much time, 2 weeks on this problem, to no avail.
  55.  
  56.     I am now desperate, pls...if anyone knows the answer, 
  57.     pls tell me what is going wrong! I am going insane.
  58.  
  59.     I have also posted this problem in the MFC group but has yet to
  60.     receive any replies.
  61.  
  62.     Pls, if anyone knows, pls answer...
  63.     I am doing this as a school project... deadline's up!!
  64.  
  65. ----------------------------------------------------------------------------
  66.  Joseph Chia                       Email:chiateck@iscs.nus.sg
  67. ----------------------------------------------------------------------------
  68.